{% extends "zinnia/base.html" %}
{% load i18n %}
{% load zinnia %}
{% load comments %}

{% block title %}{{ object.title }}{% endblock title %}

{% block meta-description %}{{ object.excerpt|safe }}{% endblock meta-description %}

{% block meta-keywords %}{% if object.tags %}{{ object.tags }}{% else %}{{ block.super }}{% endif %}{% endblock meta-keywords %}

{% block link %}
  {{ block.super }}
  {% with previous_entry=object.previous_entry %}{% if previous_entry %}
  <link rel="prev" title="{{ previous_entry.title }}" href="{{ previous_entry.get_absolute_url }}" />
  {% endif %}{% endwith %}
  {% with next_entry=object.next_entry %}{% if next_entry %}
  <link rel="next" title="{{ next_entry.title }}" href="{{ next_entry.get_absolute_url }}" />
  {% endif %}{% endwith %}
  <link rel="shortlink" href="{{ object.short_url }}" />
  <link rel="canonical" href="{{ object.get_absolute_url }}" />
  {% with year=object.publication_date|date:"Y" month=object.publication_date|date:"m" day=object.publication_date|date:"d" %}
  <link rel="alternate" type="application/rss+xml" title="{% blocktrans with object=object.title %}RSS feed of discussions on {{ object }}{% endblocktrans %}"
        href="{% url 'zinnia:entry_discussion_feed' year month day object.slug %}" />
  <link rel="alternate" type="application/rss+xml" title="{% blocktrans with object=object.title %}RSS feed of comments on {{ object }}{% endblocktrans %}"
        href="{% url 'zinnia:entry_comment_feed' year month day object.slug %}" />
  <link rel="alternate" type="application/rss+xml" title="{% blocktrans with object=object.title %}RSS feed of pingbacks on {{ object }}{% endblocktrans %}"
        href="{% url 'zinnia:entry_pingback_feed' year month day object.slug %}" />
  <link rel="alternate" type="application/rss+xml" title="{% blocktrans with object=object.title %}RSS feed of trackbacks on {{ object }}{% endblocktrans %}"
        href="{% url 'zinnia:entry_trackback_feed' year month day object.slug %}" />
  {% endwith %}
{% endblock link %}

{% block body-class %}entry entry-{{ object.pk }}{% if object.featured %} featured{% endif %} year-{{ object.publication_date|date:"Y" }} month-{{ object.publication_date|date:"m" }} week-{{ object.publication_date|date:"W" }} day-{{ object.publication_date|date:"d" }}{% endblock body-class %}

{% block content %}

{% block entry-content %}
  {% include object.content_template with object_content=object.html_content %}
{% endblock entry-content %}

{% block entry-widgets %}
<aside role="complementary" class="entry-widgets">
  {% block entry-next-entry %}
  {% with next_entry=object.next_entry %}
  {% if next_entry %}
  <div class="entry-next">
    <h3>{% trans "Next entry" %}</h3>
    <p>
      <a href="{{ next_entry.get_absolute_url }}" title="{{ next_entry.title }}" rel="next">
        {{ next_entry.title }}
      </a>
    </p>
  </div>
  {% endif %}
  {% endwith %}
  {% endblock entry-next-entry %}
  {% block entry-previous-entry %}
  {% with previous_entry=object.previous_entry %}
  {% if previous_entry %}
  <div class="entry-previous">
    <h3>{% trans "Previous entry" %}</h3>
    <p>
      <a href="{{ previous_entry.get_absolute_url }}" title="{{ previous_entry.title }}" rel="prev">
        {{ previous_entry.title }}
      </a>
    </p>
  </div>
  {% endif %}
  {% endwith %}
  {% endblock entry-previous-entry %}
  {% block entry-related-entries %}
  {% with entry_related=object.related_published %}
  {% if entry_related %}
  <div class="entry-related">
    <h3>{% trans "Related entries" %}</h3>
    <ul>
      {% for entry in entry_related %}
      <li>
	<a href="{{ entry.get_absolute_url }}" title="{{ entry.title }}" rel="bookmark">{{ entry.title }}</a>
      </li>
      {% endfor %}
    </ul>
  </div>
  {% endif %}
  {% endwith %}
  {% endblock entry-related-entries %}
  {% block entry-similar-entries %}
  <div class="entry-similar">
    <h3>{% trans "Similar entries" %}</h3>
    {% get_similar_entries %}
  </div>
  {% endblock entry-similar-entries %}
</aside>
{% endblock entry-widgets %}

{% block entry-pingbacks %}
<section id="pingbacks">
  <h3>{% trans "Pingbacks" %}</h3>
  {% if object.pingback_count %}
  {% with pingback_list=object.pingbacks %}
  {% block pingbacks-loop %}
  <ol id="pingback-list">
    {% for pingback in pingback_list %}
    <li id="pingback-{{ pingback.pk }}" class="pingback vcard {% cycle 'box1' 'box2' %}">
      {% block pingback-info %}
      <p class="pingback-info">
        {% blocktrans with pingback_url=pingback.url pingback_name=pingback.name pingback_human_date=pingback.submit_date|date:"SHORT_DATETIME_FORMAT" pingback_technical_date=pingback.submit_date|date:"c" pingback_pk=pingback.pk trimmed %}
	<a href="{{ pingback_url }}" rel="external nofollow"
           class="fn url org">{{ pingback_name }}</a>
	on
        <time class="pingback-published" datetime="{{ pingback_technical_date }}">
          {{ pingback_human_date }}
        </time>
        <a href="#pingback-{{ pingback_pk }}"
           id="c{{ pingback_pk }}" class="anchor-link"
           title="Direct link to this pingback">#</a>
        {% endblocktrans %}
      </p>
      {% endblock pingback-info %}
      {% block pingback-content %}
      <p class="pingback-content">
	{{ pingback.comment }}
      </p>
      {% endblock pingback-content %}
    </li>
    {% endfor %}
  </ol>
  {% endblock pingbacks-loop %}
  {% endwith %}
  {% endif %}
  {% block pingbacks-status %}
  {% if object.pingbacks_are_open %}
  <p>{% trans "Pingbacks are open." %}</p>
  {% else %}
  <p>{% trans "Pingbacks are closed." %}</p>
  {% endif %}
  {% endblock pingbacks-status %}
</section>
{% endblock entry-pingbacks %}

{% block entry-trackbacks %}
{% if object.trackback_count or object.trackbacks_are_open %}
<section id="trackbacks">
  <h3>{% trans "Trackbacks" %}</h3>
  {% if object.trackback_count %}
  {% with trackback_list=object.trackbacks %}
  {% block trackbacks-loop %}
  <ol id="trackback-list">
    {% for trackback in trackback_list %}
    <li id="trackback-{{ trackback.pk }}" class="trackback vcard {% cycle 'box1' 'box2' %}">
      {% block trackback-info %}
      <p class="trackback-info">
        {% blocktrans with trackback_url=trackback.url trackback_name=trackback.name trackback_human_date=trackback.submit_date|date:"SHORT_DATETIME_FORMAT" trackback_technical_date=trackback.submit_date|date:"c" trackback_pk=trackback.pk trimmed %}
	<a href="{{ trackback_url }}" rel="external nofollow"
           class="fn url org">{{ trackback_name }}</a>
	on
        <time class="trackback-published" datetime="{{ trackback_technical_date }}">
          {{ trackback_human_date }}
        </time>
        <a href="#trackback-{{ trackback_pk }}"
           id="c{{ trackback_pk }}" class="anchor-link"
           title="Direct link to this trackback">#</a>
        {% endblocktrans %}
      </p>
      {% endblock trackback-info %}
      {% block trackback-content %}
      <p class="trackback-content">
	{{ trackback.comment }}
      </p>
      {% endblock trackback-content %}
    </li>
    {% endfor %}
  </ol>
  {% endblock trackbacks-loop %}
  {% endwith %}
  {% endif %}
  {% block trackbacks-status %}
  {% if object.trackbacks_are_open %}
  <p>
    <a href="{% url 'zinnia:entry_trackback' object.pk %}" rel="trackback">
      {% trans "Trackback URL" %}</a>
  </p>
  {% endif %}
  {% endblock trackbacks-status %}
</section>
{% endif %}
{% endblock entry-trackbacks %}

{% block entry-comments %}
<section id="comments">
  <h3>{% trans "Comments" %}</h3>
  {% if object.comment_count %}
  {% with comment_list=object.comments %}
  {% block comments-loop %}
  <ol id="comment-list">
    {% for comment in comment_list %}
    <li id="comment-{{ comment.pk }}-by-{{ comment.user_name|slugify }}"
        class="comment vcard {% cycle 'box1' 'box2' %}{% if comment.user %} authenticated-comment{% if comment.user.is_staff %} staff-comment{% endif %}{% if comment.user.is_superuser %} superuser-comment{% endif %}{% endif %}">
      {% block comment-image %}
      <img src="{% get_gravatar comment.email 60 "G" %}"
           class="gravatar photo" alt="{{ comment.name }}" />
      {% endblock comment-image %}
      {% block comment-info %}
      <p class="comment-info">
        {% blocktrans with comment_url=comment.url|default:"#" comment_name=comment.name comment_human_date=comment.submit_date|date:"SHORT_DATETIME_FORMAT" comment_technical_date=comment.submit_date|date:"c" comment_pk=comment.pk comment_author_slug=comment.user_name|slugify trimmed %}
        <a href="{{ comment_url }}" rel="external nofollow"
           class="fn url">{{ comment_name }}</a>
        on
        <time class="comment-published" datetime="{{ comment_technical_date }}">
          {{ comment_human_date }}
        </time>
        <a href="#comment-{{ comment_pk }}-by-{{ comment_author_slug }}"
           id="c{{ comment_pk }}" class="anchor-link"
           title="Direct link to this comment">#</a>
        {% endblocktrans %}
      </p>
      {% endblock comment-info %}
      {% block comment-content %}
      {{ comment.comment|linebreaks }}
      {% endblock comment-content %}
    </li>
    {% endfor %}
  </ol>
  {% endblock comments-loop %}
  {% endwith %}
    {% if not object.comments_are_open %}
  <p>{% trans "Comments are closed." %}</p>
    {% endif %}
  {% else %}
    {% if object.comments_are_open %}
  <p>{% trans "No comments yet." %}</p>
    {% else %}
  <p>{% trans "Comments are closed." %}</p>
    {% endif %}
  {% endif %}
</section>
{% endblock entry-comments %}

{% block entry-comments-form %}
{% if object.comments_are_open %}
  {% render_comment_form for object %}
{% endif %}
{% endblock entry-comments-form %}

{% endblock content %}

{% block admin-tools %}
{% if perms.zinnia.change_entry %}
<li>
  <a href="{% url 'admin:zinnia_entry_change' object.pk %}" title="{% trans "Edit the entry" %}">
    {% trans "Edit the entry" %}
  </a>
</li>
{% endif %}
{% endblock admin-tools %}
